import 'package:distribution_mall_flutter/generated/json/base/json_convert_content.dart';
import 'package:distribution_mall_flutter/entity/address/address_entity.dart';

AddressEntity $AddressEntityFromJson(Map<String, dynamic> json) {
  final AddressEntity addressEntity = AddressEntity();
  final PageMeta? pageMeta = jsonConvert.convert<PageMeta>(json['pageMeta']);
  if (pageMeta != null) {
    addressEntity.pageMeta = pageMeta;
  }
  final List<AddressItem>? items = (json['items'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<AddressItem>(e) as AddressItem).toList();
  if (items != null) {
    addressEntity.items = items;
  }
  return addressEntity;
}

Map<String, dynamic> $AddressEntityToJson(AddressEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pageMeta'] = entity.pageMeta?.toJson();
  data['items'] = entity.items?.map((v) => v.toJson()).toList();
  return data;
}

extension AddressEntityExtension on AddressEntity {
  AddressEntity copyWith({
    PageMeta? pageMeta,
    List<AddressItem>? items,
  }) {
    return AddressEntity()
      ..pageMeta = pageMeta ?? this.pageMeta
      ..items = items ?? this.items;
  }
}

AddressItem $AddressItemFromJson(Map<String, dynamic> json) {
  final AddressItem addressItem = AddressItem();
  final String? distributorAddressId = jsonConvert.convert<String>(
      json['distributorAddressId']);
  if (distributorAddressId != null) {
    addressItem.distributorAddressId = distributorAddressId;
  }
  final String? distributorId = jsonConvert.convert<String>(
      json['distributorId']);
  if (distributorId != null) {
    addressItem.distributorId = distributorId;
  }
  final String? recipientName = jsonConvert.convert<String>(
      json['recipientName']);
  if (recipientName != null) {
    addressItem.recipientName = recipientName;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    addressItem.phone = phone;
  }
  final String? country = jsonConvert.convert<String>(json['country']);
  if (country != null) {
    addressItem.country = country;
  }
  final String? province = jsonConvert.convert<String>(json['province']);
  if (province != null) {
    addressItem.province = province;
  }
  final String? city = jsonConvert.convert<String>(json['city']);
  if (city != null) {
    addressItem.city = city;
  }
  final String? district = jsonConvert.convert<String>(json['district']);
  if (district != null) {
    addressItem.district = district;
  }
  final String? street = jsonConvert.convert<String>(json['street']);
  if (street != null) {
    addressItem.street = street;
  }
  final String? detailInfo = jsonConvert.convert<String>(json['detailInfo']);
  if (detailInfo != null) {
    addressItem.detailInfo = detailInfo;
  }
  final String? backupDetailInfo = jsonConvert.convert<String>(
      json['backupDetailInfo']);
  if (backupDetailInfo != null) {
    addressItem.backupDetailInfo = backupDetailInfo;
  }
  final String? zip = jsonConvert.convert<String>(json['zip']);
  if (zip != null) {
    addressItem.zip = zip;
  }
  final String? virtualPostcode = jsonConvert.convert<String>(
      json['virtualPostcode']);
  if (virtualPostcode != null) {
    addressItem.virtualPostcode = virtualPostcode;
  }
  final bool? isDef = jsonConvert.convert<bool>(json['isDef']);
  if (isDef != null) {
    addressItem.isDef = isDef;
  }
  return addressItem;
}

Map<String, dynamic> $AddressItemToJson(AddressItem entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['distributorAddressId'] = entity.distributorAddressId;
  data['distributorId'] = entity.distributorId;
  data['recipientName'] = entity.recipientName;
  data['phone'] = entity.phone;
  data['country'] = entity.country;
  data['province'] = entity.province;
  data['city'] = entity.city;
  data['district'] = entity.district;
  data['street'] = entity.street;
  data['detailInfo'] = entity.detailInfo;
  data['backupDetailInfo'] = entity.backupDetailInfo;
  data['zip'] = entity.zip;
  data['virtualPostcode'] = entity.virtualPostcode;
  data['isDef'] = entity.isDef;
  return data;
}

extension AddressItemExtension on AddressItem {
  AddressItem copyWith({
    String? distributorAddressId,
    String? distributorId,
    String? recipientName,
    String? phone,
    String? country,
    String? province,
    String? city,
    String? district,
    String? street,
    String? detailInfo,
    String? backupDetailInfo,
    String? zip,
    String? virtualPostcode,
    bool? isDef,
  }) {
    return AddressItem()
      ..distributorAddressId = distributorAddressId ?? this.distributorAddressId
      ..distributorId = distributorId ?? this.distributorId
      ..recipientName = recipientName ?? this.recipientName
      ..phone = phone ?? this.phone
      ..country = country ?? this.country
      ..province = province ?? this.province
      ..city = city ?? this.city
      ..district = district ?? this.district
      ..street = street ?? this.street
      ..detailInfo = detailInfo ?? this.detailInfo
      ..backupDetailInfo = backupDetailInfo ?? this.backupDetailInfo
      ..zip = zip ?? this.zip
      ..virtualPostcode = virtualPostcode ?? this.virtualPostcode
      ..isDef = isDef ?? this.isDef;
  }
}

PageMeta $PageMetaFromJson(Map<String, dynamic> json) {
  final PageMeta pageMeta = PageMeta();
  final int? pageNum = jsonConvert.convert<int>(json['pageNum']);
  if (pageNum != null) {
    pageMeta.pageNum = pageNum;
  }
  final int? pageSize = jsonConvert.convert<int>(json['pageSize']);
  if (pageSize != null) {
    pageMeta.pageSize = pageSize;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    pageMeta.total = total;
  }
  final int? pages = jsonConvert.convert<int>(json['pages']);
  if (pages != null) {
    pageMeta.pages = pages;
  }
  return pageMeta;
}

Map<String, dynamic> $PageMetaToJson(PageMeta entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pageNum'] = entity.pageNum;
  data['pageSize'] = entity.pageSize;
  data['total'] = entity.total;
  data['pages'] = entity.pages;
  return data;
}

extension PageMetaExtension on PageMeta {
  PageMeta copyWith({
    int? pageNum,
    int? pageSize,
    int? total,
    int? pages,
  }) {
    return PageMeta()
      ..pageNum = pageNum ?? this.pageNum
      ..pageSize = pageSize ?? this.pageSize
      ..total = total ?? this.total
      ..pages = pages ?? this.pages;
  }
}

AddressDeliveryTimeEntity $AddressDeliveryTimeEntityFromJson(
    Map<String, dynamic> json) {
  final AddressDeliveryTimeEntity addressDeliveryTimeEntity = AddressDeliveryTimeEntity();
  final String? deliveryAddressId = jsonConvert.convert<String>(
      json['deliveryAddressId']);
  if (deliveryAddressId != null) {
    addressDeliveryTimeEntity.deliveryAddressId = deliveryAddressId;
  }
  final String? logisticsProductId = jsonConvert.convert<String>(
      json['logisticsProductId']);
  if (logisticsProductId != null) {
    addressDeliveryTimeEntity.logisticsProductId = logisticsProductId;
  }
  final String? logisticsProductCode = jsonConvert.convert<String>(
      json['logisticsProductCode']);
  if (logisticsProductCode != null) {
    addressDeliveryTimeEntity.logisticsProductCode = logisticsProductCode;
  }
  final String? logisticsProductName = jsonConvert.convert<String>(
      json['logisticsProductName']);
  if (logisticsProductName != null) {
    addressDeliveryTimeEntity.logisticsProductName = logisticsProductName;
  }
  final String? logisticsId = jsonConvert.convert<String>(json['logisticsId']);
  if (logisticsId != null) {
    addressDeliveryTimeEntity.logisticsId = logisticsId;
  }
  final String? logisticsCode = jsonConvert.convert<String>(
      json['logisticsCode']);
  if (logisticsCode != null) {
    addressDeliveryTimeEntity.logisticsCode = logisticsCode;
  }
  final String? logisticsName = jsonConvert.convert<String>(
      json['logisticsName']);
  if (logisticsName != null) {
    addressDeliveryTimeEntity.logisticsName = logisticsName;
  }
  final String? carrierId = jsonConvert.convert<String>(json['carrierId']);
  if (carrierId != null) {
    addressDeliveryTimeEntity.carrierId = carrierId;
  }
  final String? carrierCode = jsonConvert.convert<String>(json['carrierCode']);
  if (carrierCode != null) {
    addressDeliveryTimeEntity.carrierCode = carrierCode;
  }
  final String? carrierName = jsonConvert.convert<String>(json['carrierName']);
  if (carrierName != null) {
    addressDeliveryTimeEntity.carrierName = carrierName;
  }
  final String? transportType = jsonConvert.convert<String>(
      json['transportType']);
  if (transportType != null) {
    addressDeliveryTimeEntity.transportType = transportType;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    addressDeliveryTimeEntity.description = description;
  }
  final int? minDeliveryTime = jsonConvert.convert<int>(
      json['minDeliveryTime']);
  if (minDeliveryTime != null) {
    addressDeliveryTimeEntity.minDeliveryTime = minDeliveryTime;
  }
  final int? maxDeliveryTime = jsonConvert.convert<int>(
      json['maxDeliveryTime']);
  if (maxDeliveryTime != null) {
    addressDeliveryTimeEntity.maxDeliveryTime = maxDeliveryTime;
  }
  return addressDeliveryTimeEntity;
}

Map<String, dynamic> $AddressDeliveryTimeEntityToJson(
    AddressDeliveryTimeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['deliveryAddressId'] = entity.deliveryAddressId;
  data['logisticsProductId'] = entity.logisticsProductId;
  data['logisticsProductCode'] = entity.logisticsProductCode;
  data['logisticsProductName'] = entity.logisticsProductName;
  data['logisticsId'] = entity.logisticsId;
  data['logisticsCode'] = entity.logisticsCode;
  data['logisticsName'] = entity.logisticsName;
  data['carrierId'] = entity.carrierId;
  data['carrierCode'] = entity.carrierCode;
  data['carrierName'] = entity.carrierName;
  data['transportType'] = entity.transportType;
  data['description'] = entity.description;
  data['minDeliveryTime'] = entity.minDeliveryTime;
  data['maxDeliveryTime'] = entity.maxDeliveryTime;
  return data;
}

extension AddressDeliveryTimeEntityExtension on AddressDeliveryTimeEntity {
  AddressDeliveryTimeEntity copyWith({
    String? deliveryAddressId,
    String? logisticsProductId,
    String? logisticsProductCode,
    String? logisticsProductName,
    String? logisticsId,
    String? logisticsCode,
    String? logisticsName,
    String? carrierId,
    String? carrierCode,
    String? carrierName,
    String? transportType,
    String? description,
    int? minDeliveryTime,
    int? maxDeliveryTime,
  }) {
    return AddressDeliveryTimeEntity()
      ..deliveryAddressId = deliveryAddressId ?? this.deliveryAddressId
      ..logisticsProductId = logisticsProductId ?? this.logisticsProductId
      ..logisticsProductCode = logisticsProductCode ?? this.logisticsProductCode
      ..logisticsProductName = logisticsProductName ?? this.logisticsProductName
      ..logisticsId = logisticsId ?? this.logisticsId
      ..logisticsCode = logisticsCode ?? this.logisticsCode
      ..logisticsName = logisticsName ?? this.logisticsName
      ..carrierId = carrierId ?? this.carrierId
      ..carrierCode = carrierCode ?? this.carrierCode
      ..carrierName = carrierName ?? this.carrierName
      ..transportType = transportType ?? this.transportType
      ..description = description ?? this.description
      ..minDeliveryTime = minDeliveryTime ?? this.minDeliveryTime
      ..maxDeliveryTime = maxDeliveryTime ?? this.maxDeliveryTime;
  }
}